# Based on https://github.com/kubernetes-csi/external-attacher/blob/master/Dockerfile
{{- range $key, $value := .CandiVersionMap.k8s }}
  {{- $version := toString $key }}
  {{- if $value.csi.attacher }}
---
image: {{ $.ModuleName }}/{{ $.ImageName }}-{{ $version | replace "." "-" }}
fromImage: common/distroless
import:
  - artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
    add: /csi-attacher
    to: /csi-attacher
    before: setup
docker:
  ENTRYPOINT: ["/csi-attacher"]
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
from: {{ $.Images.BASE_GOLANG_21_ALPINE_DEV }}
shell:
  beforeInstall:
    - git clone --depth 1 --branch {{ $value.csi.attacher }} {{ $.SOURCE_REPO }}/kubernetes-csi/external-attacher.git /src
  install:
    - export GO_VERSION=${GOLANG_VERSION} GOPROXY={{ $.GOPROXY }} CGO_ENABLED=0 GOOS=linux GOARCH=amd64
    - cd /src
    {{- if semverCompare "<1.29" $version }}
    - go get golang.org/x/net@v0.17.0
    - go get google.golang.org/grpc@v1.57.2
    - go mod tidy
    - go mod vendor
    {{- end }}
    - make build
    - cp bin/csi-attacher /csi-attacher
    - chown 64535:64535 /csi-attacher
    - chmod 0755 /csi-attacher
  {{- end }}
{{- end }}
